package org.houor;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class JdbcInitServlet
 */
@WebServlet(urlPatterns = { "/JdbcInitServlet" }, loadOnStartup = 1)
public class JdbcInitServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	DbUtil dd = new DbUtil();

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public JdbcInitServlet() {
		super();
	}

	public void init(ServletConfig config) throws ServletException {

		dd.getConnection();

		config.getServletContext().setAttribute("conn", dd.getDbConn());

	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	@Override
	public void destroy() {
		dd.closeConnection();

		super.destroy();
	}

}
